import store from '@/store/index.js';
import restUtil from '@/utils/restUtil.js';
var SaveCommand = function() {

};

SaveCommand.prototype.execute = function() {
	var nodeList = store.state.workflowDesigner.nodeList;
	var lineList = store.state.workflowDesigner.lineList;
	var workflow={
		nodeList:nodeList,
		lineList:lineList,
		"code": store.state.workflowDesigner.createContext.code,
		"name":store.state.workflowDesigner.currentWorkflow.name,
		"formCode":store.state.workflowDesigner.currentWorkflow.formCode,
		"mobileFormCode":store.state.workflowDesigner.currentWorkflow.mobileFormCode,
		"documentExpression":store.state.workflowDesigner.currentWorkflow.documentExpression,
		"startEventExpression":store.state.workflowDesigner.currentWorkflow.startEventExpression,
		"endEventExpression":store.state.workflowDesigner.currentWorkflow.endEventExpression,
	}
	let workflowJson = JSON.stringify(workflow);
	var request = {
		"code": store.state.workflowDesigner.createContext.code,
		"name":store.state.workflowDesigner.currentWorkflow.name,
		"formCode":store.state.workflowDesigner.currentWorkflow.formCode,
		"mobileFormCode":store.state.workflowDesigner.currentWorkflow.mobileFormCode,
		"irModelId":store.state.workflowDesigner.currentWorkflow.irModelId,
		"displayColumnList":store.state.workflowDesigner.displayColumnList.join(","),
		"workflowJson": workflowJson,
		"currentElementId":store.state.workflowDesigner.createContext.currentElementId
	};
	restUtil.postAction(store.state.workflowDesigner, "devworkflowdesigner/dataSave", request).then(
		function(response) {
			if (response.data.code == 1) {
				store.state.workflowDesigner.$alert('保存成功', '提示');
			} else {
				store.state.workflowDesigner.$alert(response.data.message, '提示');
			}
		});
};
export default SaveCommand
